<!DOCTYPE html>
<html lang="en">
<head>
    <th:block th:include="include :: header('物业费缴纳信息')" />
    <style>
        h5{
            width: 160px;
            display: inline;
        }
        .form-select{
            width: 100px;
            display: inline;
        }
        .container{
            margin-bottom: 100px;
        }
    </style>
</head>
<body>
<h3 class="text-center">物业费缴纳信息</h3><br/>
<div class="container">
    <div class="text-center">
        <h5>楼号</h5>&nbsp;&nbsp;
        <select class="form-select" aria-label="Default select example" id="buildingNo">
            <option selected>全部</option>
            <option value="1">1号</option>
            <option value="2">2号</option>
            <option value="3">3号</option>
        </select>&nbsp;&nbsp;
        <h5>房号</h5>&nbsp;&nbsp;
        <select class="form-select" aria-label="Default select example" id="roomNo">
            <option selected>全部</option>
            <option value="1">0101</option>
            <option value="2">0102</option>
            <option value="3">0201</option>
            <option value="4">0202</option>
            <option value="5">0301</option>
            <option value="6">0302</option>
            <option value="7">0401</option>
            <option value="8">0402</option>
            <option value="9">0501</option>
            <option value="10">0502</option>
            <option value="11">0601</option>
            <option value="12">0602</option>
            <option value="13">0701</option>
            <option value="14">0702</option>
        </select>&nbsp;&nbsp;
        <h5>年份</h5>&nbsp;&nbsp;
        <select class="form-select" aria-label="Default select example" id="year">
            <option selected>全部</option>
            <option value="1">2018</option>
            <option value="2">2019</option>
            <option value="3">2020</option>
            <option value="4">2021</option>
            <option value="5">2022</option>
        </select>&nbsp;&nbsp;
        <h5>月份</h5>&nbsp;&nbsp;
        <select class="form-select" aria-label="Default select example" id="month">
            <option selected>全部</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
        </select>&nbsp;&nbsp;
        <h5>是否已缴费</h5>&nbsp;&nbsp;
        <select class="form-select" aria-label="Default select example" id="whether">
            <option selected>全部</option>
            <option value="1">是</option>
            <option value="2">否</option>
        </select>&nbsp;&nbsp;
        <button type="button" class="btn btn-primary" onclick="clickConfirm()">确认</button>
    </div><br/>

    <table class="table table-hover align-middle">
        <thead style="background-color: azure">
        <tr>
            <th scope="col">楼号</th>
            <th scope="col">房号</th>
            <th scope="col">年份</th>
            <th scope="col">月份</th>
            <th scope="col">物业费用</th>
            <th scope="col">是否已缴费</th>
            <th scope="col">缴费日期</th>
            <th scope="col">缴费人</th>
            <th scope="col">缴费单号</th>
        </tr>
        </thead>
        <tbody id="tbody">
        <tr th:each="propertyFee:${propertyfee}">
            <td th:text="${propertyFee.getBuildingNo().trim()}"></td>
            <td th:text="${propertyFee.getRoomNo().trim()}"></td>
            <td th:text="${propertyFee.getYear().trim()}"></td>
            <td th:text="${propertyFee.getMonth().trim()}"></td>
            <td th:text="${propertyFee.getPropertyFee().trim()}"></td>
            <td th:text="${propertyFee.getWhether().trim()}"></td>
            <td th:text="${propertyFee.getFeeDate().trim()}"></td>
            <td th:text="${propertyFee.getPeoName().trim()}"></td>
            <td th:text="${propertyFee.getOdd().trim()}"></td>
        </tr>
        </tbody>
    </table>
</div>
<script th:src="@{/js/jquery.min.js}"></script>
<script>
    $(function () {
        $.get("/queryInfo/residentInfo/buildingNoAndRoomNo",function (data){
            let buildingNo = data.buildingNo;
            let roomNo = data.roomNo;
            $("#buildingNo").empty();//清空下拉框
            let  buildingNoSelect = "<option selected>全部</option>";
            $("#buildingNo").append(buildingNoSelect);
            $.each(buildingNo,function (i) {
                buildingNoSelect = "<option>"+buildingNo[i].trim()+"</option>"
                $("#buildingNo").append(buildingNoSelect);
            })
            $("#roomNo").empty();//清空下拉框
            let  roomNoSelect = "<option selected>全部</option>";
            $("#roomNo").append(roomNoSelect);
            $.each(roomNo,function (i) {
                roomNoSelect = "<option>"+roomNo[i].trim()+"</option>"
                $("#roomNo").append(roomNoSelect);
            })
        })
    })
    clickConfirm = function (){
        $.get("/queryInfo/residentPayInfo/condition",
            {
                buildingNo:$("#buildingNo option:selected").text(),
                roomNo:$("#roomNo option:selected").text(),
                year:$("#year option:selected").text(),
                month:$("#month option:selected").text(),
                whether:$("#whether option:selected").text()
            },
            function (data,status){
                $("#tbody").empty();//清空表格
                $.each(data,function (i) {
                    let  tbody = "<tr><td>"+data[i].buildingNo.trim()+"</td>"
                        +"<td>"+data[i].roomNo.trim()+"</td>"
                        +"<td>"+data[i].year.trim()+"</td>"
                        +"<td>"+data[i].month.trim()+"</td>"
                        +"<td>"+data[i].propertyFee.trim()+"</td>"
                        +"<td>"+data[i].whether.trim()+"</td>"
                        +"<td>"+data[i].feeDate.trim()+"</td>"
                        +"<td>"+data[i].peoName.trim()+"</td>"
                        +"<td>"+data[i].odd.trim()+"</td>";
                    $("#tbody").append(tbody);
                })
            })
    }
</script>

</body>
</html>